﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DBSchemaReader
{
	public static class SqlDataReadExtensions
	{
		public static int? GetInt32Nullable(this SqlDataReader dr, string p)
		{
			int ordinal = dr.GetOrdinal(p);

			if (dr.IsDBNull(ordinal))
				return null;

			return dr.GetInt32(ordinal);
		}

		public static string GetString(this SqlDataReader dr, string columnName)
		{
			return dr.GetString(dr.GetOrdinal(columnName));
		}
	}
}
